#include "delay.h"

// delay_us
void delay_us(uint32_t us)
{
    SysTick->LOAD = us * 72;
    SysTick->VAL = 0x00;
    SysTick->CTRL = 0x00000005;
    while (!(SysTick->CTRL & 0x00010000))
        ;
    SysTick->CTRL = 0x00000004;
}

// delay_ms
void delay_ms(uint32_t ms)
{
    while (ms--)
    {
        delay_us(1000);
    }
}

// delay_s
void delay_s(uint32_t s)
{
    while (s--)
    {
        delay_ms(1000);
    }
}